package com.jarvis.pzz.modules.sourceshop.adapter;

import android.view.View;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.bumptech.glide.Glide;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.jarvis.pzz.R;
import com.jarvis.pzz.models.MyPublishShopsListModel;

import java.util.List;

/**
 * Created by Administrator
 * on 2017/9/28.
 */

public class SourceShopAdapter extends BaseQuickAdapter<MyPublishShopsListModel.shopPulishBaean> {

    public SourceShopAdapter(int layoutResId, List<MyPublishShopsListModel.shopPulishBaean> data) {
        super(layoutResId, data);
    }

    @Override
    protected void convert(BaseViewHolder baseViewHolder, MyPublishShopsListModel.shopPulishBaean shopListModel) {


        ImageView tv_shopThumbnailImgPath = baseViewHolder.getView(R.id.tv_shopThumbnailImgPath);
        TextView tv_shopTitle = baseViewHolder.getView(R.id.tv_shopTitle);
        TextView tv_shopStateText = baseViewHolder.getView(R.id.tv_shopStateText);
        TextView tv_shopPrice = baseViewHolder.getView(R.id.tv_shopPrice);
        ImageView im_modify = baseViewHolder.getView(R.id.im_modify);
        LinearLayout ll_delete = baseViewHolder.getView(R.id.ll_delete);
        TextView tv_time = baseViewHolder.getView(R.id.tv_time);

        Glide.with(mContext).load(shopListModel.getShopThumbnailImgPath()).placeholder(R.drawable.img_default).error(R.drawable.img_default).into(tv_shopThumbnailImgPath);
        tv_shopTitle.setText(shopListModel.getShopTitle());
        tv_shopStateText.setText(shopListModel.getShopStateText());

        if (shopListModel.getShopPrice().equals("0")) {
            tv_shopPrice.setText("面试");
        } else {
            String ShopRentType = "";
            if ("年租金".equals(shopListModel.getShopRentType())) {
                ShopRentType = "万元/年";
            }else if ("月租金".equals(shopListModel.getShopRentType())) {
                ShopRentType = "元/月";
            }

            tv_shopPrice.setText(shopListModel.getShopPrice() + ShopRentType);
        }

        tv_time.setText(shopListModel.getCreateTime());

        ll_delete.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                //删除
            }
        });

        im_modify.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                //修改
            }
        });


    }
}
